package com.company.modules.project.controller;

import com.company.common.utils.R;
import com.company.modules.project.service.DepartmentService;
import com.company.modules.project.entity.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : Real
 * @date : 2022/1/12 19:31
 * @description : 部门控制层
 */
@RestController
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @RequestMapping(path = "/department/list", method = RequestMethod.GET)
    public R getDepartmentList() {
        List<Department> departmentList = departmentService.findAllDepartment();
        if (departmentList == null) {
            return R.error("没有公司列表，请联系管理员");
        } else {
            return R.ok().put("data", departmentList);
        }
    }

}
